package com.ruiysoft.service.order.facade;
//
//
//import com.ruiysoft.controller.mdse.InnrApi;
//import com.ruiysoft.entity.order.OrderDetail;
//import com.ruiysoft.entity.order.OrderMain;
//import com.ruiysoft.entity.order.OrderPay;
//import com.ruiysoft.pub.core.Result;
//import com.ruiysoft.pub.core.ResultGenerator;
//import com.ruiysoft.service.mdse.bean.MerchandiseStoceEnvelope;
//import com.ruiysoft.service.order.IOrderMainService;
//import com.ruiysoft.service.order.IOrderPayService;
//import com.ruiysoft.service.order.consts.OrderDBStatusEnum;
//import com.ruiysoft.service.order.consts.OrderPayStatusEnum;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.annotation.Resource;
//import java.util.Date;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * Date : 2018/11/29
// *
// * @author WenJialu
// */
//@Component
//public class OrderSysFacade {
//
//	@Resource
//	IOrderMainService orderMainService;
//	@Resource
//	IOrderPayService orderPayService;
//	@Resource
//	OrderPubFacade orderPubFacade;
//	@Resource
//	private InnrApi innrMdseApi;
//
//	@Transactional
//	public Result orderCancel(String orderNo){
//		Date now = new Date();
//		OrderMain omRecord = new OrderMain()
//				.setStatus(OrderDBStatusEnum.ORDER_CANCELLED.getCode())
//				.setCancelTime(now)
//				.setRemark("支付超时自动取消");
//		orderMainService.update(omRecord
//				, new EntityWrapper<OrderMain>()
//						.eq("order_no", orderNo)
//						.eq("status", OrderDBStatusEnum.CUSTOMER_CONFIRMED_WAITING_FOR_PAYMENT.getCode())
//						.eq("del_flag", false));
//
//		OrderPay opRecord = new OrderPay()
//				.setStatus(OrderPayStatusEnum.PAY_CANCEL.getCode())
//				.setUpdateTime(now)
//				.setMessage("支付超时自动取消");
//		orderPayService.update(opRecord
//				, new EntityWrapper<OrderPay>()
//						.eq("order_no", orderNo)
//						.eq("status", OrderPayStatusEnum.WAITING_FOR_PAY.getCode()));
//
//		//获取订单商品
//		List<OrderDetail> orderDetails = orderPubFacade.getOrderDetails(orderNo);
//		//库存
//		innrMdseApi.innrMdseDerBatchPost(orderDetails
//				.stream()
//				.map(vo -> new MerchandiseStoceEnvelope()
//						.setSkuId(vo.getSkuId())
//						.setNum(0 - vo.getQuantity()))
//				.collect(Collectors.toList()));
//
//		//操作记录
//		return ResultGenerator.genSuccessResult();
//	}
//
//}
